<?php
/***************************************************************
*  Copyright notice
*  (c) 2009, jianyuzhu@gmail.com
*  All rights reserved
*  This script is part of the PPEMI project.
***************************************************************/

class CorePathway {
	var $pathways;
	
	//constructor
	function CorePathway() {
		$this->pathways = array();
	}
	
	function setHome($type) {
		if( $type ) {
			$this->has_home = true;
		} else {
			$this->has_home = false;
		}
	}
	
	//methods
	function add($text, $link = '', $type = 'link') {
		if( $link == '' ) {
			$this->pathways[] = array('text' => $text, 'link' => '', 'type' => 'text');
		} else {
			$this->pathways[] = array('text' => $text, 'link' => $link, 'type' => 'link');
		}
	}
	
	function output() {
		return $this->_output();
	}
	
	//
	function _output() {
		$content = '';
		
		$content .= '<ul class="pathway">';
		if( $this->has_home == true ) {
			$content .= '<li class="h"><a href="' . CONFIG_URL_HTTP . '">' . 'Home' . '</a></li>';
		}
		if( is_array($this->pathways) ) {
			foreach($this->pathways as $k => $v) {
				if( $v['type'] == 'link' ) {
					$content .= '<li><a href="' . CONFIG_URL_HTTP . $v['link'] . CONFIG_URL_SUFFIX . '">' . $v['text'] . '</a></li>';
				} else {
					$content .= '<li>' . $v['text'] . '</li>';
				}
			}
		}
		$content .= '</ul>';
		
		return $content;
	}
}
//
?>